<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link href="css/applyList.css" rel="stylesheet" type="text/css">
    <title>员工列表</title>
</head>
<body>
<!--header-->
<div class="top_box">
    <div id="" class="top">
        <div class="top_left">企业级视频直播解决方案</div>
        <div class="top_right"><a href="">关于我们&nbsp;&nbsp;</a>▏服务热线：400-048-2820</div>
        <div class="clearfix"></div>
    </div>
</div>
<div class="header_box">
    <div class="header">
        <div class="logo">
              <a href="#"><img src="images/logo1.png"></a>
        </div>
        <ul class="tab_menu">
        </ul>
        <div class="clearfix"></div>
    </div>
</div>
<!--main-->
<div class="main clearfix">
<a  href="loginOut" style="padding:8px 14px;background-color: #2d92dd;float: right;color: #fff;margin-top: 15px;margin-right: 15px;cursor: pointer;display: inline-block;">退出</a>
    <ul class="main_left">
     	<li><a href="applyList">申请列表</a></li>
     	<li><a  href="contractList?firstPartyName=${null }" >合同列表</a></li>
        <li><a href="javascript:void(0)" style="color:#AEEEEE">员工列表</a></li>
    </ul>
        <div class="main_right">
        <label style="color:#AEEEEE">员工列表</label>
    <table>
        <thead>
            <tr>
         	    <th>登陆账号</th>
                <th>姓名</th>
                <th>状态</th>
                <th>角色</th>
                <th>上次登陆时间</th>
                <th>备注</th>
                 <c:if test="${ sessionScope.CurrentUser.role==1 }">
                <th style="width: 150px;">操作</th>
                </c:if>
                 <c:if test="${ sessionScope.CurrentUser.role==2 }">
                <th style="width: 80px;">操作</th>
                </c:if>
            </tr>
            <c:forEach var="admin" items="${ requestScope.adminList}" varStatus="st">
		 <tr>
                <td>${admin.name}</td>
                <td>${admin.account}</td>
                <td id="${admin.id}"><c:if test="${admin.special == 0 }">正常</c:if>
                <c:if test="${admin.special == 1 }">缺勤</c:if> </td>
                <td ><c:if test="${admin.role == 2 }">销售人员</c:if></td>
                 <td>${admin.landingTime}</td>
                <td>${admin.comments}</td>
                <td>
              	 <button class="gengxin" onclick="showDialog(${admin.id});">更新</button>
              	 <c:if test="${ sessionScope.CurrentUser.role==1 }">
               	 <button class="chongzhi" onclick="PasswordOnclick(${admin.id});">重置密码</button>
               	 </c:if>
                </td>
            </tr>
				</c:forEach>
        </thead>
    </table>
    </div>
    <div class="clearfix"></div>
    <ul class="fenye clearfix">
        <li><a href="adminList?pageIndex=1">首页</a></li>
        <li><a href="adminList?pageIndex=${pageIndex-1}">上一页</a></li>
        <li><a style="color: #2d92dd">共有${totalCount}条记录，当前第${pageIndex}/${totalPage}页</a></li>
        <li><a <c:if test="${pageIndex < totalPage}"> href="adminList?pageIndex=${pageIndex+1}" </c:if>>下一页</a></li>
        <li><a href="adminList?pageIndex=${totalPage}">末页</a></li>
    </ul>
</div>

<!--弹框-->
<div class="add_group_main" id="add_group_main" style="z-index: 100;">
	<input type="hidden" id="adminId">
  	<p style="float:left;padding-left: 7px;margin-bottom:5px;margin-left:80px;">状态：<select name="special" id="special" style="width: 180px;border:1px solid #999; height:30px;padding-left:9px;line-height:30px;">
							<option value="0" style="color: #000">正常</option>
							<option value="1" style="color: #000">缺勤</option>
					</select>
					</p>
					<div class="clearfix"></div>
    <p><input type="button" id="cancelGroup" value="取消" class="anniu" style="background:#f1f1f1;color:#666;margin:5px 0 15px 5px;"><input class="anniu" type="button" onclick="updateApply();" value="确认" style="margin:5px 5px 15px;"></p>
</div>
<div class="body-color"></div>
<!--foot-->
<div class="footer_box">
    <div class="footer">
        <p>Copyright@2016&nbsp;ZoomCloud&nbsp;盟视科技,&nbsp; All&nbsp; right&nbsp; reserved.&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.miit.gov.cn" style="color: #8b97b1; text-decoration: none !important">沪ICP备15017725号</a> </p>
    </div>
</div>
<script src="js/jquery-1.7.2.js"></script>
<script type="text/javascript">
    function PasswordOnclick(id){
    	$.ajax({
			type: "POST",
			url: 'updatePassword',
	    	data: {id:id },
	    	dataType: "html",
			cache: false,
			success: function(data){
				if(data == "success"){
					alert("重置成功!");
				}
				else alert("重置失败，请重试!");
			}
		});
    	}
    jQuery(document).ready(function($) {
        $('.gengxin').click(function(){
            $('.body-color').fadeIn(100);
            $('#add_group_main').slideDown(200);
        })
        $('#cancelGroup').click(function(){
            $('.body-color').fadeOut(100);
            $('#add_group_main').slideUp(200);
        })

    })
    function showDialog(id){
        $('.body-color').fadeIn(100);
        $('#add_group_main').slideDown(200);
        $("#adminId").val(id);
    }
    function updateApply(){
    	var adminId = $("#adminId").val();
    	var  myselect=document.getElementById("special");
    	var index=myselect.selectedIndex; 
    	var	 special =myselect.options[index].value;
    	$.ajax({
			type: "POST",
			url: 'updateAdmin',
	    	data: {id:adminId ,special :special },
	    	dataType: "html",
			cache: false,
			success: function(data){
				if(data == "success"){
					$('.body-color').fadeOut(100);
		            $('#add_group_main').slideUp(200);
		            window.location.href=window.location.href; 
		            window.location.reload; 
				}
				else alert("修改失败，请重试!");
			}
		});
    	
   }
</script>

</body>
</html>